package com.lemon.cloud.command;

import com.lemon.cloud.representation.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author lemon
 * @version 1.0
 * @description: TODO
 * @date Create by lemon on 2019-09-14 21:42
 */
@Component
public class DefaultCommandBus implements CommandBus {
    @Autowired
    private CommandRepository commandRepository;

    @Override
    public <R extends Response, C extends Command> R send(C command) {
        return (R) this.commandRepository.getCommandInvocation(command.getClass()).invoke(command);
    }
}
